{extend name="base" /}
{block name="content"}
<div class="content">
    <div class="container-fluid">
        <!-- Page-Title -->
    <div class="row">
        <div class="col-12">
            <div class="page-title-box">
                <div class="page-title-right">
                    <ol class="breadcrumb m-0">
                        <li class="breadcrumb-item"><a href="{:url('index/index')}"><i class="fe-home"></i> 控制台</a></li>
                        <li class="breadcrumb-item"><a href="javascript: void(0);">菜单管理</a></li>
                        <li class="breadcrumb-item active">菜单列表</li>
                    </ol>
                </div>
                <h4 class="page-title"> <i class="fe-lock"></i> 权限管理</h4>
            </div>
        </div>
        <div class="col-lg-12">
            <!-- <div class="alert alert-success alert-dismissable">
                <button type="button" class="close" data-dismiss="alert" aria-hidden="true"></button>
                <i class="mdi mdi-alert-circle-outline mr-2"></i>排序提示：数值越小越排在前面
            </div>   -->
            <div class="card-box">
                <div class="table-responsive">
                <a href="{:url('accesses/add')}" class="btn btn-sm btn-success waves-effect waves-light float-right"><i class="mdi mdi-plus-circle"></i> 添加权限节点</a>
                <h4 class="header-title mb-4">权限列表</h4>
                    <table class="tablesaw table table-hover">
                        <thead>
                            <tr>
                                <th>权限名称</th>
                                <th>权限节点</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            {empty name="$list"}
                            <tr>
                                <td colspan="4" id="colspanTbal">
                                    <span class="fe-alert-triangle"></span> 暂无权限数据～
                                </td>
                            </tr>
                            {/empty}
                            {foreach $list as $key => $val}
                            <tr>
                                <td>{$val['_name']}</td>
                                <td>{$val.sign}</td>
                                <td>
                                <a href="{:url('accesses/edit', array('id' => $val['id']))}" class="badge badge-success"  data-toggle="tooltip" data-placement="top" data-original-title="编辑" style="float: none;"><i class="fe-edit"></i></a>

                                <a href="javascript:;" onclick="del(this)" data-id="{$val.id}" class="badge badge-danger"  data-toggle="tooltip" data-placement="top" data-original-title="删除" style="float: none;"><i class="fe-trash-2"></i></a>
                                </td>
                            </tr>
                            {/foreach}
                        </tbody>
                    </table>

                </div>
                <!--分页位置-->
            </div>
        </div> <!-- end col -->

        
    </div>
    </div> <!-- container -->

</div> <!-- content -->
<script src="/static/layui/layui.js"></script>
<script type="text/javascript">
    layui.use(['element', 'form', 'layedit','upload'], function () {
        var form = layui.form;
        var $ = layui.jquery,upload = layui.upload;
    })
    function del(e){
        var id = $(e).attr('data-id')
        layer.confirm('确认删除？', {
            btn: ['确定','取消'],
            title: '操作提示',
            icon: 7,
        }, function(){
            $.post('/admin/accesses/del',{id:id},function(res){
                if(res.code == 0){
                    layer.msg(res.message,{icon:1, shade: [0.2, '#ccc'], time:800});
                    // window.open(res.data);
                    $(e).parents("tr").remove();
                }else{
                    layer.msg(res.message,{icon:5, anim: 6});
                }
            },'json');
        });     
    }
</script>
{/block}